#include "MTBlock.hpp"
#include "MTStatement.hpp"
#include <string>
#include <iostream>
#include <sstream>

namespace MathematicaTranslator
{
	std::string* MTBlock::generateCode(CodeGenContext& context)
	{
		std::ostringstream ss;

		for (int i = statements.size() - 1; i >= 0; --i){		
			std::string *text = statements[i]->generateCode(context);
			ss << *text;
			if (text->length() > 0) ss << ";\n";
		}

		#ifdef DEBUG
		std::cout << "MTBlock created" << std::endl;
		#endif

		return new std::string(ss.str());
	}
}